package com.sl.hx.shop.ui.classify.presenter;

import android.content.Context;

import com.sl.hx.shop.base.BasePresenter;
import com.sl.hx.shop.bean.GoodsClassify;
import com.sl.hx.shop.http.ApiFactory;
import com.sl.hx.shop.http.ApiRetrofit;
import com.sl.hx.shop.http.HttpUtil;
import com.sl.hx.shop.http.ProgressSubscribe;
import com.sl.hx.shop.ui.classify.contacts.ClassifyContacts;
import com.trello.rxlifecycle2.android.FragmentEvent;

import java.util.List;

import io.reactivex.Observable;

public class ClassifyPresenter extends BasePresenter<ClassifyContacts.view> implements ClassifyContacts.presenter {

    private Context mContext;


    public ClassifyPresenter(Context context) {
        this.mContext=context;

    }

    public void getCate() {
        Observable observable = ApiFactory.getInstance().getCate(ApiRetrofit.getCacheControl());
        HttpUtil.getInstance().toSubscribe(observable, new ProgressSubscribe<List<GoodsClassify>>(mContext) {
            @Override
            protected void _onNext(List<GoodsClassify> goodsClassifyList) {
                getView().ShowCate(goodsClassifyList);
            }
            @Override
            protected void _onError(String message) {
            }
        }, true,getView(), FragmentEvent.DESTROY);
    }
}
